package com.czh.springboot04.service.serviceimpl;

import com.czh.springboot04.entity.FM;
import com.czh.springboot04.mapper.FMMapper;
import com.czh.springboot04.service.FMService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class FMServiceImpl implements FMService {
    @Autowired
    private FMMapper fmMapper;
    @Override
    public int fmAdd(FM fm) {
        int num = fmMapper.fmAdd(fm);

        return num;
    }

    @Override
    public int fmUpdate(FM fm) {
        int num = fmMapper.fmUpdate(fm);
        return num;
    }

    @Override
    public int fmDelete(int id) {
        int num = fmMapper.fmDelete(id);
        return num;
    }

    @Override
    public PageInfo<FM> fmSelectAll(int pageNum, int pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<FM> fms = fmMapper.fmSelectAll();
        PageInfo<FM> fms1 = new PageInfo<>(fms);
        return fms1;
    }

    @Override
    public PageInfo<FM> fmByMoreTable(int pageNum, int pageSize) {
        PageHelper.startPage(pageNum,pageSize);
       List<FM> fms = fmMapper.fmByMoreTable();
       PageInfo<FM> fms1 = new PageInfo<>(fms);
       return fms1;
    }

    @Override
    public PageInfo<FM> fmSelectByName(int pageNum, int pageSize, String name) {

        PageHelper.startPage(pageNum,pageSize);
        List<FM> fms = fmMapper.fmSelectByName(name);
        PageInfo<FM> fms1 = new PageInfo<>(fms);
        return fms1;
    }


}
